/* Location scenes own the viewport; dialogs remain in the game's existing overlay layer. */
body.world-location-open { overflow: hidden; }
body.world-location-open .topbar,
body.world-location-open .status-bar,
body.world-location-open #leftSidebar,
body.world-location-open #rightSidebar { display: none !important; }
body.world-location-open #worldLocationPage:not([hidden]) {
  position: fixed; inset: 0; z-index: 25; width: 100%; height: 100dvh;
  min-height: 0; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden;
  color: #e8e0ce; background: #121310;
}
body.world-location-open #worldLocationScene,
body.world-location-open #worldLocationScene > .world-location-scene__overlay {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; gap: 0;
}
body.world-location-open #worldLocationScene { background-size: cover; background-position: center; }
body.world-location-open #worldLocationScene > .world-location-scene__overlay {
  display: block; background: linear-gradient(#080a09dd, #080a09a8 24%, #080a09b8 65%, #080a09e8);
}
body.world-location-open #worldLocationPage .world-location-header {
  position: absolute; inset: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) auto max(20px, env(safe-area-inset-left));
  z-index: 4; display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none;
  pointer-events: none; text-shadow: 0 2px 5px #000;
}
body.world-location-open .world-location-header .eyebrow,
body.world-location-open #worldLocationDescription { display: none; }
body.world-location-open #worldLocationName { margin: 0; font-size: clamp(1rem, 1.7vw, 1.5rem); }
body.world-location-open .world-location-header .world-page__header-actions { display: flex; width: auto; gap: 12px; align-items: center; flex-wrap: nowrap; }
body.world-location-open #worldLocationBackButton { pointer-events: auto; min-height: 44px; }
body.world-location-open #worldLocationDanger { border: 0; background: none; padding: 0; font-size: .75rem; }
body.world-location-open #expeditionRoot { position: absolute; inset: 0; }
body.world-location-open .expedition-layout { position: absolute; inset: 0; display: block; border: 0; border-radius: 0; overflow: hidden; }
body.world-location-open .expedition-stage {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; overflow: hidden;
  transform: none;
}
body.world-location-open .expedition-backdrop {
  width: 100%; height: 100%; object-fit: cover; object-position: center;
}
body.world-location-open .expedition-hud {
  position: absolute; z-index: 4; top: max(68px, calc(env(safe-area-inset-top) + 54px)); left: 20px; right: 20px;
  display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; font-size: .75rem; text-shadow: 0 2px 4px #000;
}
body.world-location-open .expedition-route-label { flex-basis: auto; margin-right: 0; color: #d5c6a8; letter-spacing: .05em; }
body.world-location-open .expedition-bag { margin: 0; min-height: 36px; padding: 6px 10px; }
body.world-location-open .expedition-noise { margin-left: auto; }
body.world-location-open .expedition-noise-bars i.is-filled { background: #c4ac79; }
body.world-location-open .expedition-progress { color: #d8d0bf; }
body.world-location-open .expedition-scene-caption { bottom: 52px; background: none; text-align: center; text-shadow: 0 2px 5px #000; pointer-events: none; }
body.world-location-open .expedition-footer { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 20px; right: 20px; z-index: 3; padding: 0; justify-content: center; }
body.world-location-open .expedition-field-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
body.world-location-open :is(.expedition-bag, .expedition-field-actions .button, #worldLocationBackButton) {
  color: #e4dccb; background: #141611c9; border: 1px solid #b9a88560; border-radius: 3px; box-shadow: 0 3px 12px #0005;
}
body.world-location-open :is(.expedition-bag, .expedition-field-actions .button, #worldLocationBackButton):hover { background: #393427ed; border-color: #c8b585; }
body.world-location-open .expedition-detail:not([hidden]) {
  position: absolute; z-index: 5; right: 20px; top: 116px; bottom: 76px; width: min(340px, calc(100% - 40px));
  height: fit-content; max-height: calc(100% - 192px); overflow: auto; overscroll-behavior: contain;
  padding: 22px; color: #e4dccb; background: linear-gradient(115deg, #22221af5, #111410f5);
  border: 1px solid #b9a88566; border-radius: 3px; box-shadow: 0 12px 55px #0009; animation: field-detail-in .2s ease-out;
}
body.world-location-open .expedition-detail h3 { padding-right: 30px; outline: none; }
.expedition-detail-close { position: absolute; right: 6px; top: 6px; width: 44px; height: 44px; color: #dfd4bc; background: none; border: 0; font-size: 1.5rem; cursor: pointer; }
body.world-location-open .expedition-method { background: #3a3628; border-color: #bca77b66; border-radius: 3px; }
body.world-location-open .expedition-method:hover:not(:disabled) { background: #514831; border-color: #d9c494; }
body.world-location-open .expedition-pin__dot { color: #e6d8af; border-color: #d3bf87; background: #1a1c14b8; }
body.world-location-open .expedition-pin:is(:hover, :focus-visible, .is-selected) .expedition-pin__dot { background: #a48f55; color: #11150d; }
body.world-location-open .expedition-pin__label { color: #e5dcc7; background: #11150cc9; }
body.world-location-open .world-location-actions-panel:not([hidden]) {
  position: absolute; left: 20px; bottom: 76px; z-index: 4; width: min(340px, calc(100% - 40px));
  max-height: calc(100% - 200px); overflow: auto; padding: 0; border: 0; background: none; box-shadow: none; backdrop-filter: none;
}
body.world-location-open .world-location-actions-panel > .section-heading { display: none; }
body.world-location-open .world-location-actions-panel > summary { width: fit-content; padding: 12px 16px; color: #e4dccb; background: #242319ef; border: 1px solid #b9a88588; cursor: pointer; border-radius: 3px; font-weight: 700; }
body.world-location-open .world-location-actions-panel[open] > summary { margin-bottom: 8px; }
body.world-location-open .world-location-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; }
body.world-location-open .world-location-actions .action-card { padding: 12px; background: #191b14ed; border-color: #b9a88566; }
body.world-location-open .world-location-actions .action-card img { max-height: 100px; object-fit: cover; }
@keyframes field-detail-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) and (orientation: portrait) {
  body.world-location-open #worldLocationPage .world-location-header { left: 12px; right: 12px; gap: 6px; }
  body.world-location-open .world-location-header .world-page__header-actions { gap: 4px; }
  body.world-location-open #worldLocationDanger { display: none; }
  body.world-location-open #worldLocationBackButton { font-size: .7rem; padding: 6px; width: auto; }
  body.world-location-open .expedition-hud { left: 12px; right: 12px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; font-size: .62rem; }
  body.world-location-open .expedition-hud > * { grid-column: span 2; min-width: 0; }
  body.world-location-open .expedition-hud > .expedition-vitals { grid-column: span 4; }
  body.world-location-open .expedition-noise { margin-left: 0; }
  body.world-location-open .expedition-bag { flex: 1; min-height: 36px; font-size: .65rem; }
  body.world-location-open .expedition-stage { top: 164px; bottom: auto; left: 50%; right: auto; width: 100%; height: auto; aspect-ratio: 16 / 9; transform: translateX(-50%); }
  body.world-location-open .expedition-scene-caption { bottom: 0; padding: 4px; font-size: .6rem; }
  body.world-location-open .expedition-detail:not([hidden]) { top: calc(164px + 56.25vw); bottom: 96px; max-height: calc(100% - 260px - 56.25vw); right: 12px; width: calc(100% - 24px); padding: 12px; }
  body.world-location-open .expedition-detail .expedition-eyebrow { display: none; }
  body.world-location-open .expedition-detail h3 { font-size: 1rem; margin: 0 0 8px; }
  body.world-location-open .expedition-detail p { font-size: .75rem; margin: 6px 0; line-height: 1.4; }
  body.world-location-open .expedition-method { padding: 8px; margin-top: 6px; }
  body.world-location-open .expedition-previews { display: none; }
  body.world-location-open .expedition-detail > small { display: none; }
  body.world-location-open .expedition-footer { left: 12px; right: 12px; bottom: max(8px, env(safe-area-inset-bottom)); }
  body.world-location-open .expedition-field-actions { width: 100%; gap: 5px; }
  body.world-location-open .expedition-field-actions .button { flex: 1 1 45%; min-height: 36px; font-size: .66rem; padding: 6px; }
  body.world-location-open .world-location-actions-panel:not([hidden]) { left: 12px; bottom: 94px; max-height: calc(100% - 244px - 56.25vw); width: calc(100% - 24px); }
}
@media (max-width: 700px) and (max-height: 700px) and (orientation: portrait) {
  /* Short phones use an inspection overlay instead of squeezing actions below the artwork. */
  body.world-location-open .expedition-detail:not([hidden]) { top: 164px; max-height: calc(100% - 260px); }
  body.world-location-open .world-location-actions-panel:not([hidden]) { max-height: calc(100% - 244px); }
}
@media (max-height: 500px) and (orientation: landscape) {
  body.world-location-open .expedition-hud { top: 58px; gap: 6px 10px; font-size: .6rem; }
  body.world-location-open .expedition-bag { min-height: 30px; font-size: .6rem; }
  body.world-location-open .expedition-detail:not([hidden]) { top: 98px; bottom: 58px; max-height: calc(100% - 156px); padding: 12px; width: 290px; }
  body.world-location-open .expedition-footer .button { min-height: 32px; padding: 6px 10px; font-size: .65rem; }
}
@media (prefers-reduced-motion: reduce) { body.world-location-open .expedition-detail { animation: none; } }

/* A small provisions pouch, not another inventory window. */
.expedition-supplies {
  position: absolute; z-index: 8; top: 116px; right: 20px; width: min(360px, calc(100% - 40px));
  max-height: calc(100% - 192px); overflow: auto; overscroll-behavior: contain;
  padding: 16px; background: #191b14f5; border: 1px solid #b9a88588; border-radius: 3px; box-shadow: 0 12px 50px #0009;
}
.expedition-supplies h3 { margin: 0 34px 16px 0; font-size: 1rem; }
.expedition-supplies h4 { margin: 12px 0 6px; color: #d3bf87; }
.expedition-supplies p { margin: 4px 0; font-size: .75rem; color: #b6b3a8; }
.expedition-supply-items { display: grid; gap: 6px; }
.expedition-supply-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px; text-align: left; border: 1px solid #b9a88555; color: #e4dccb; background: #302e22; cursor: pointer; }
.expedition-supply-item img { width: 38px; height: 38px; object-fit: contain; }
.expedition-supply-item:disabled { opacity: .45; cursor: not-allowed; }
.expedition-supply-item:hover:not(:disabled) { background: #4a422e; }
@media (max-width: 700px) and (orientation: portrait) {
  .expedition-supplies { top: 164px; right: 12px; width: calc(100% - 24px); max-height: calc(100% - 260px); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .expedition-supplies { top: 98px; max-height: calc(100% - 156px); }
}

/* Patreon callout on field/location scenes. Reuse the existing global Patreon link. */
body.world-location-open .topbar {
  display: block !important;
  position: fixed !important;
  z-index: 90 !important;
  inset: 0 !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  pointer-events: none !important;
}
body.world-location-open .topbar > div:first-child { display: none !important; }
body.world-location-open .topbar__actions {
  position: fixed !important;
  right: max(20px, env(safe-area-inset-right)) !important;
  bottom: max(20px, env(safe-area-inset-bottom)) !important;
  display: block !important;
  margin: 0 !important;
  pointer-events: auto !important;
}
body.world-location-open .patreon-button {
  min-width: 214px !important;
  min-height: 52px !important;
  padding: 10px 18px !important;
  gap: 10px !important;
  border: 1px solid rgba(255,255,255,.34) !important;
  border-radius: 8px !important;
  color: #fff !important;
  background: #ff424d !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.18) !important;
  font-size: .88rem !important;
  font-weight: 800 !important;
  letter-spacing: .01em !important;
  text-shadow: 0 1px 2px rgba(0,0,0,.28) !important;
  animation: location-patreon-callout 11s ease-in-out infinite;
  transform: none !important;
}
body.world-location-open .patreon-button__icon {
  width: 25px !important;
  height: 25px !important;
  flex: 0 0 25px !important;
  stroke: currentColor !important;
}
body.world-location-open .patreon-button:hover,
body.world-location-open .patreon-button:focus-visible {
  background: #ff5660 !important;
  border-color: rgba(255,255,255,.72) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 0 4px rgba(255,66,77,.18), 0 0 28px rgba(255,66,77,.42) !important;
  filter: none !important;
  transform: translateY(-1px) !important;
}
@keyframes location-patreon-callout {
  0%, 67%, 100% {
    box-shadow: 0 8px 24px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.18);
    filter: brightness(1);
  }
  72% {
    box-shadow: 0 8px 26px rgba(0,0,0,.44), 0 0 0 4px rgba(255,66,77,.14), 0 0 28px rgba(255,66,77,.42), inset 0 1px rgba(255,255,255,.22);
    filter: brightness(1.08);
  }
  77% {
    box-shadow: 0 8px 24px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.18);
    filter: brightness(1);
  }
  82% {
    box-shadow: 0 8px 28px rgba(0,0,0,.46), 0 0 0 5px rgba(255,66,77,.12), 0 0 34px rgba(255,66,77,.48), inset 0 1px rgba(255,255,255,.24);
    filter: brightness(1.1);
  }
  88% {
    box-shadow: 0 8px 24px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.18);
    filter: brightness(1);
  }
}
@media (max-width: 700px) {
  body.world-location-open .topbar__actions {
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }
  body.world-location-open .patreon-button {
    min-width: 0 !important;
    min-height: 42px !important;
    padding: 8px 11px !important;
    font-size: .72rem !important;
  }
  body.world-location-open .patreon-button__icon {
    width: 21px !important;
    height: 21px !important;
    flex-basis: 21px !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.world-location-open .patreon-button { animation: none !important; }
}

/* Landscape phones are wider than the legacy 760px phone breakpoint. Treat
   short coarse-pointer viewports as mobile without changing laptop/tablet UI. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) and (max-width: 980px) {
  /* Never shrink dialogs to tiny touch targets on landscape phones. */
  .modal.modal--viewport-fit {
    place-items: start center !important;
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .modal--viewport-fit > .modal__content,
  .modal--viewport-fit > .combat-panel {
    width: min(100%, calc(100vw - 16px)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 16px) !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    zoom: 1 !important;
    transform: none !important;
  }

  .modal--viewport-fit .dashboard-workspace,
  .modal--viewport-fit .modal__content--quest-scene {
    width: min(100%, calc(100vw - 16px)) !important;
    height: auto !important;
    max-height: none !important;
  }

  .modal--viewport-fit .dashboard-workspace__body,
  .modal--viewport-fit .dashboard-view,
  .modal--viewport-fit .resident-modal__scroll,
  .modal--viewport-fit .equipment-item-list,
  .modal--viewport-fit .loot-inventory-list,
  .modal--viewport-fit .cheat-loot-list,
  .modal--viewport-fit .save-slots-list,
  .modal--viewport-fit .quest-list,
  .modal--viewport-fit .training-list,
  .modal--viewport-fit .crafting-list {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .modal--viewport-fit .dashboard-resident-list,
  .modal--viewport-fit .dashboard-upgrade-list,
  .modal--viewport-fit .equipment-item-list,
  .modal--viewport-fit .loot-inventory-list,
  .modal--viewport-fit .save-slots-list,
  .modal--viewport-fit .quest-list,
  .modal--viewport-fit .training-list,
  .modal--viewport-fit .crafting-list {
    grid-template-columns: 1fr !important;
  }

  .modal--viewport-fit .dashboard-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Keep map/settlement gameplay in a single usable column on phone landscape. */
  body.world-page-open .layout,
  body.settlement-page-open .layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.world-page-open #leftSidebar,
  body.world-page-open #rightSidebar,
  body.settlement-page-open #leftSidebar,
  body.settlement-page-open #rightSidebar {
    display: none !important;
  }

  /* Patreon remains available, but it no longer occupies the action bar area. */
  body.world-location-open .topbar__actions {
    top: max(8px, env(safe-area-inset-top)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: auto !important;
  }

  body.world-location-open .patreon-button {
    min-width: 0 !important;
    min-height: 40px !important;
    padding: 7px 10px !important;
    font-size: .68rem !important;
  }

  body.world-location-open .patreon-button__icon {
    width: 20px !important;
    height: 20px !important;
    flex-basis: 20px !important;
  }

  body.world-location-open .expedition-footer {
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
  }

  body.world-location-open .expedition-field-actions {
    padding-right: 0;
  }
}
